//
//  PEBatterClusterFormCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/10/27.
//

#import "RHBatteryClusterFormCell.h"
@interface RHBatteryClusterFormCell()

@property (nonatomic, strong) QMUILabel *temperatureContentLab;

@property (nonatomic, strong) QMUILabel *voltageContentLab;

@property (nonatomic, strong) QMUILabel *resistanceContentLab;

@end
@implementation RHBatteryClusterFormCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setupUI];
    }
    return self;
}

-(void)setCellModel:(RHDevCellModel *)cellModel
{
    _cellModel = cellModel;
    self.temperatureContentLab.text = [NSString stringWithFormat:@"%@℃",ValidNullDataToString(cellModel.temp, @"--")];
    self.voltageContentLab.text = [NSString stringWithFormat:@"%@mV",ValidNullDataToString(cellModel.volt, @"--")];
    self.resistanceContentLab.text = [NSString stringWithFormat:@"%@mΩ",ValidNullDataToString(cellModel.resistance, @"--")];
}

-(void)setupUI
{
    self.contentView.backgroundColor = CFTabViewBgColor;
    kWeakSelf;
    
    UIView *bgView = kView;
    bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(0, 15, 0, 15));
    }];
    
    _packNoLab = [[QMUILabel alloc]init];
    _packNoLab.text = @"Cell No: --";
    _packNoLab.font = [UIFont systemFontOfSize:13];
    _packNoLab.textAlignment = NSTextAlignmentLeft;
    _packNoLab.textColor = kCOLOR_HEX(@"3F4443");
    [bgView addSubview:_packNoLab];
    
    
    UIView *bgView1 = kView;
    bgView1.backgroundColor = CFTabViewBgColor;
    bgView1.layer.cornerRadius = 8;
    bgView1.layer.masksToBounds = YES;
    [bgView addSubview:bgView1];

    
    [bgView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.equalTo(weakSelf.packNoLab.mas_bottom).offset(15);
        make.bottom.offset(-15);
        make.height.offset(kScaleW(80));
    }];
    
    
    
    UIView *line1 = kView;
    line1.backgroundColor = kCOLOR_HEX(@"E7E7E7");
    [bgView1 addSubview:line1];
    
    UIView *line2 = kView;
    line2.backgroundColor = kCOLOR_HEX(@"E7E7E7");
    [bgView1 addSubview:line2];
    
    
    //温度
    QMUILabel *temperatureTitleLab = [[QMUILabel alloc]init];
    temperatureTitleLab.text = [NSString stringWithFormat:@"%@:",@"温度".rh_localized];
    temperatureTitleLab.font = [UIFont systemFontOfSize:15];
    temperatureTitleLab.textAlignment = NSTextAlignmentCenter;
    temperatureTitleLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.6];
    [bgView1 addSubview:temperatureTitleLab];
    
    _temperatureContentLab = [[QMUILabel alloc]init];
    _temperatureContentLab.text = @"--℃";
    _temperatureContentLab.font = [UIFont systemFontOfSize:15];
    _temperatureContentLab.textAlignment = NSTextAlignmentCenter;
    _temperatureContentLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.8];
    [bgView1 addSubview:_temperatureContentLab];
    
    //电压
    QMUILabel *voltageTitleLab = [[QMUILabel alloc]init];
    voltageTitleLab.text = [NSString stringWithFormat:@"%@:",@"电压".rh_localized];
    voltageTitleLab.font = [UIFont systemFontOfSize:15];
    voltageTitleLab.textAlignment = NSTextAlignmentCenter;
    voltageTitleLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.6];
    [bgView1 addSubview:voltageTitleLab];
    
    _voltageContentLab = [[QMUILabel alloc]init];
    _voltageContentLab.text = @"--mV";
    _voltageContentLab.font = [UIFont systemFontOfSize:15];
    _voltageContentLab.textAlignment = NSTextAlignmentCenter;
    _voltageContentLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.8];
    [bgView1 addSubview:_voltageContentLab];
    
    
    //内阻
//    QMUILabel *resistanceTitleLab = [[QMUILabel alloc]init];
//    resistanceTitleLab.text = [NSString stringWithFormat:@"%@:",@"内阻".rh_localized];
//    resistanceTitleLab.font = [UIFont systemFontOfSize:15];
//    resistanceTitleLab.textAlignment = NSTextAlignmentCenter;
//    resistanceTitleLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.6];
//    [bgView1 addSubview:resistanceTitleLab];
//    
//    _resistanceContentLab = [[QMUILabel alloc]init];
//    _resistanceContentLab.text = @"--mΩ";
//    _resistanceContentLab.font = [UIFont systemFontOfSize:15];
//    _resistanceContentLab.textAlignment = NSTextAlignmentCenter;
//    _resistanceContentLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.8];
//    [bgView1 addSubview:_resistanceContentLab];
    
    _temperatureContentLab = [[QMUILabel alloc]init];
    _temperatureContentLab.text = @"85,796";
    _temperatureContentLab.font = [UIFont systemFontOfSize:15];
    _temperatureContentLab.textAlignment = NSTextAlignmentCenter;
    _temperatureContentLab.textColor = kCOLOR_HEX(@"3F4443");
    [bgView1 addSubview:_temperatureContentLab];
    
    
 
    [_packNoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.top.mas_offset(5);
        make.height.offset(20);
    }];
    
    
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.top.mas_offset(15);
        make.bottom.mas_offset(-15);
        make.width.offset(1);
    }];
    
//    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_offset(-(kUI_WINDOW_W-30)/3);
//        make.top.mas_offset(15);
//        make.bottom.mas_offset(-15);
//        make.width.offset(1);
//    }];
   

    [temperatureTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_offset(10);
        make.left.mas_offset(0);
        make.right.equalTo(line1.mas_left);
    }];
    
    
    [_temperatureContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(temperatureTitleLab);
        make.right.equalTo(temperatureTitleLab);
        make.centerY.mas_offset(-10);
    }];
    
    
    
    [voltageTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(line1.mas_right);
        make.right.mas_offset(0);
        make.centerY.equalTo(temperatureTitleLab);
    }];
    
    [_voltageContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(line1.mas_right);
        make.right.mas_offset(0);
        make.centerY.equalTo(weakSelf.temperatureContentLab);
    }];
    
//    [resistanceTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(line2.mas_right);
//        make.right.mas_offset(0);
//        make.centerY.equalTo(voltageTitleLab);
//    }];
//    
//    [_resistanceContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(line2.mas_right);
//        make.right.mas_offset(0);
//        make.centerY.equalTo(weakSelf.voltageContentLab);
//        
//    }];
    
}

@end
